import request from '../utils/request.js'

export const cakeGet = (page=0,bcid=1)=>{
	let skip = page*10
	return request.get('/classes/Cake',{
		params:{
			limit:10,
			skip,
			where:{bcid}
		}
	})
}

//批量录入数据
export const cakeBatch = (list)=>{
	let requests = list.map(item=>{
		return {
			"method": "POST",
			"path": "/1.1/classes/Cake1",
			"body": item
		}
	})
	return request.post('/batch',{requests})
}

//新增购物车数据
export const cartPost = (userId,cartList)=>{
	return request.post('/classes/Cart',{
		userId,
		cartList
	})
}
//根据用户id，获取购物车数据
export const cartGet = (userId)=>{
	return request.get(`/classes/Cart`,{
		params:{
			where:{userId}
		}
	})
}

//更新购物车
export const cartPut = (cartId,cartList)=>{
	return request.put(`/classes/Cart/${cartId}`,{
		cartList
	})
}